package com.code.user.service.mapper;

import com.code.AZPlan.model.bo.UserVipBO;
import com.code.AZPlan.model.po.WithdrawOrder;
import com.code.commons.dao.CrudMapper;
import com.code.user.model.bo.SystemSettingBO;
import com.code.user.model.bo.UserCertificationBO;
import com.code.user.model.bo.UserRecommenderBO;
import com.code.user.model.po.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 用户持久层映射接口
 *
 * @author tangyifei
 * @since 2019-5-24 10:23:26
 */
@Repository
public interface UserMapper extends CrudMapper<User> {

    User getUserCredential(@Param("id") String id);

    int rechargeCoinBalance(RechargeTranRecord rechargeTranRecord);

    int reduceCoinBalance(RechargeTranRecord rechargeTranRecord);

    String getUserIdByUserPhone(@Param("userPhone") String userPhone);

    String getUserIdByUserEmail(@Param("userEmail") String userEmail);

    LoginUserCredential getUserByPhone(@Param("userPhone") String userPhone);

    Integer getRecommenderIndex(@Param("recommenderPhone") String recommenderPhone);

    void resetPwd(@Param("userId") String userId, @Param("newPwd") String newPwd, @Param("updateTime") Date updateTime);

    void addUserCoinBalanceDefaultInfo(List<Map<String, Object>> userCoinBalanceMaps);

    int addCoinBalance(UserCoinBalance userCoinBalance);

    int addUSDTCoinBalance(@Param("userId") String userId, @Param("coinBalance") BigDecimal coinBalance,
                           @Param("coinType") String coinType, @Param("version") Integer version,
                           @Param("updateTime") Date updateTime);

    int insertUserRecommender(UserRecommender userRecommender);

//    int insertUserRecommenderIncome(UserRecommenderIncome userRecommenderIncome);

    void updateUserCoinAddress(UserCoinBalance userCoinBalance);

    void updateCoinAmount(UserCoinBalance userCoinBalance);

    void updateOrePool(@Param("userId") String userId, @Param("orePool") BigDecimal orePool,
                       @Param("azPlanStatus") Integer azPlanStatus, @Param("version") Integer version,
                       @Param("updateTime") Date updateTime);

    void insertUserAZPlanChannelList(List<UserAZPlanChannel> userAZPlanChannelList);

    void insertAZPlanBalance(Map<String, Object> azBalanceMap);

    void insertAZPlanMoneyTransferList(List<Map<String, Object>> azMoneyTransferMaps);

    void insertAZWalletList(List<Map<String, Object>> azWalletMaps);

    List<UserAZPlanChannel> getAZPlanChannelList(@Param("userId") String userId, @Param("coinType") String coinType);

    Integer getOrePoolVersion(@Param("userId") String userId);

    Integer getUserCoinBalanceVersion(@Param("userId") String userId, @Param("coinType") String coinType);

    UserCoinBalance getUserCoinBalance(UserCoinBalance userCoinBalance);

    WithdrawOrder getWithdrawOrder(@Param("id") String id);

    UserToken getUserTokenByPhone(@Param("phone") String phone);

    List<UserToken> getTokenList(List<UserVipBO> userVipBOS);

    String getUserCoinAddressByUserId(@Param("userId") String userId, @Param("coinType") String coinType);

    List<UserCoinBalance> getUserWalletList(@Param("coinType") String coinType);

    List<UserCoinBalance> getUserCoinBalanceList(@Param("userId") String userId);

    List<String> getUserPhones(@Param("phone") String phone);

    void insertRechargeFlow(Map<String, Object> rechargeFlow);

    void updateUserToken(@Param("mobilePhone") String mobilePhone, @Param("tokenId") String tokenId, @Param("updateTime") Date updateTime);

    void insertUserToken(UserToken userTokenForDB);

    int insertRechargeTranRecordList(List<RechargeTranRecord> rechargeTranRecordList);

    int insertRechargeTranRecord(RechargeTranRecord rechargeTranRecord);

    BigDecimal getTotalRechargeAmount(@Param("userId") String userId, @Param("coinType") String coinType,
                                      @Param("coinAddress") String coinAddress);

    int reduceUserCoinBalance(UserCoinBalance userCoinBalance);

    int updateWithdrawOrderCheckState(@Param("id") String id, @Param("checkTime") Date checkTime);

    List<UserRecommenderBO> getRecommendsByUserId(@Param("userId") String userId, @Param("entryMoneyState") Integer entryMoneyState);

    int getRecommendsCountByUserId(@Param("userId") String userId, @Param("entryMoneyState") Integer entryMoneyState);

    String getRecommendIdByRecommendUserId(@Param("userId") String userId);

    int getRecommendUserAmount(@Param("userId") String userId);

    int addUserCertification(UserCertification userCertification);

    int updateUserCertification(UserCertification userCertification);

    UserCertification getUserCertificationByUserId(@Param("userId") String userId);

    int getUserCertificationCountByCertificationNumber(@Param("certificationNumber") String certificationNumber);

    List<UserCertification> getUserCertificationList(UserCertificationBO userCertificationBO);

    SystemSettingBO getSystemSettingBOBySystemKey(@Param("systemKey") String systemKey);

    int updateSystemProtect(SystemSettingBO systemSettingBO);

    int updateUserOperateAuth(UserOperateAuth userOperateAuth);

    int addUserOperateAuth(UserOperateAuth userOperateAuth);

    UserOperateAuth getUserOperateAuthByUserIdAndOperateCode(@Param("userId") String userId, @Param("operateCode") String operateCode);
}
